package com.uhuibao.tmall.api.domain.vo;


import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 充值请求参数
 *
 * @author haungzj
 * @date 2023-09-25
 */
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class OrderChargeRequest {

    @NotNull(message = "tbOrderNo不能为空")
    private Long tbOrderNo;

    @NotNull(message = "bizType不能为空")
    @NotBlank(message = "bizType不能为空")
    private String bizType;

    @NotNull(message = "spuId不能为空")
    private Long spuId;

    @NotNull(message = "accountVal不能为空")
    @NotBlank(message = "accountVal不能为空")
    private String accountVal;

    @NotNull(message = "supplierId不能为空")
    private Long supplierId;

    @NotNull(message = "timeStart不能为空")
    @NotBlank(message = "timeStart不能为空")
    private String timeStart;

    @NotNull(message = "timeLimit不能为空")
    private Long timeLimit;

    @NotNull(message = "buyNum不能为空")
    private Long buyNum;

    @NotNull(message = "unitPrice不能为空")
    private Long unitPrice;

    @NotNull(message = "totalPrice不能为空")
    private Long totalPrice;

    @NotNull(message = "buyerId不能为空")
    private Long buyerId;

    @NotNull(message = "notifyUrl不能为空")
    @NotBlank(message = "notifyUrl不能为空")
    private String notifyUrl;

    @NotNull(message = "ts不能为空")
    private Long ts;

    @NotNull(message = "properties不能为空")
    @NotBlank(message = "properties不能为空")
    private String properties;

    @NotNull(message = "sign不能为空")
    @NotBlank(message = "sign不能为空")
    private String sign;

    public Long getTbOrderNo() {
        return tbOrderNo;
    }

    public void setTbOrderNo(Long tbOrderNo) {
        this.tbOrderNo = tbOrderNo;
    }

    public String getBizType() {
        return bizType;
    }

    public void setBizType(String bizType) {
        this.bizType = bizType;
    }

    public Long getSpuId() {
        return spuId;
    }

    public void setSpuId(Long spuId) {
        this.spuId = spuId;
    }

    public String getAccountVal() {
        return accountVal;
    }

    public void setAccountVal(String accountVal) {
        this.accountVal = accountVal;
    }

    public Long getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Long supplierId) {
        this.supplierId = supplierId;
    }

    public String getTimeStart() {
        return timeStart;
    }

    public void setTimeStart(String timeStart) {
        this.timeStart = timeStart;
    }

    public Long getTimeLimit() {
        return timeLimit;
    }

    public void setTimeLimit(Long timeLimit) {
        this.timeLimit = timeLimit;
    }

    public Long getBuyNum() {
        return buyNum;
    }

    public void setBuyNum(Long buyNum) {
        this.buyNum = buyNum;
    }

    public Long getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(Long unitPrice) {
        this.unitPrice = unitPrice;
    }

    public Long getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(Long totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Long getBuyerId() {
        return buyerId;
    }

    public void setBuyerId(Long buyerId) {
        this.buyerId = buyerId;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public Long getTs() {
        return ts;
    }

    public void setTs(Long ts) {
        this.ts = ts;
    }

    public String getProperties() {
        return properties;
    }

    public void setProperties(String properties) {
        this.properties = properties;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public Long getDecodedTbOrderNo() {
        return tbOrderNo;
    }

    public String getDecodedBizType() {
        return decodeParam(bizType);
    }

    public Long getDecodedSpuId() {
        return spuId;
    }

    public String getDecodedAccountVal() {
        return decodeParam(accountVal);
    }

    public Long getDecodedSupplierId() {
        return supplierId;
    }

    public String getDecodedTimeStart() {
        return decodeParam(timeStart);
    }

    public Long getDecodedTimeLimit() {
        return timeLimit;
    }

    public Long getDecodedBuyNum() {
        return buyNum;
    }

    public Long getDecodedUnitPrice() {
        return unitPrice;
    }

    public Long getDecodedTotalPrice() {
        return totalPrice;
    }

    public Long getDecodedBuyerId() {
        return buyerId;
    }

    public String getDecodedNotifyUrl() {
        return decodeParam(notifyUrl);
    }

    public Long getDecodedTs() {
        return ts;
    }

    public String getDecodedProperties() {
        return decodeParam(properties);
    }

    public String getDecodedSign() {
        return decodeParam(sign);
    }

    private String decodeParam(String param) {
        if (param != null) {
            try {
                // 手动进行URL解码
                return URLDecoder.decode(param, "GBK");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}
